package com.swust.book_shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.swust.book_shop.constant.ServiceConstant;
import com.swust.book_shop.pojo.UserInfo;
import com.swust.book_shop.pojo.vo.AuthVo;
import com.swust.book_shop.service.UserInfoService;
import com.swust.book_shop.mapper.UserInfoMapper;
import org.springframework.stereotype.Service;

/**
* @author 86151
* @description 针对表【user_info】的数据库操作Service实现
* @createDate 2022-05-04 23:17:06
*/
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
    implements UserInfoService{

    @Override
    public boolean doAuth(AuthVo authVo) throws Exception {
        UserInfo userInfo = baseMapper.selectById(authVo.getId());
        userInfo.setIdNumber(authVo.getIdCard());
        if(ServiceConstant.ENABLE_UP_BOOK.equals(userInfo.getIsUpBook())){
            throw new Exception("用户已经实名认证,请勿重复操作");
        }
        userInfo.setIsUpBook("1");
        int i = baseMapper.updateById(userInfo);
        return  i>0;
    }
}




